#include "Command.h"
#include <iostream>
#define ARGMAX 50
#define TOKENMAX 10
using namespace std;
Command::Command(string com, string arguments){
    command = string(com);
    args =  (char**)malloc(TOKENMAX * sizeof(char*));
    memset(args, NULL, TOKENMAX);
    for (int i = 0; i < TOKENMAX; i++){
        args[i] = (char*)malloc(ARGMAX * sizeof(char));
        memset(args[i], NULL, ARGMAX);
    }
    for(int i = 0; i < command.size(); i++)
        args[0][i] = command.at(i);
    int index = 1;
    int currentChar = 0;

    for(int j = 0; j < arguments.size(); j++){
        if(arguments.at(j) == ' '){
            args[index][currentChar] = '\0';
            index++;
            currentChar = 0;
        }

        else{
            args[index][currentChar] = arguments.at(j);
            currentChar++;

        }
        if(j == arguments.size() - 1){
                args[index][j+1] = '\0';

             index++;
        }


    }

        args[index] = NULL; //Null terminated








}




